package com.cn.wanxi.servlet.back.product;

import com.cn.wanxi.model.ResultModel;
import com.cn.wanxi.service.IproductService;
import com.cn.wanxi.service.impl.ProductServiceImpl;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/productDelById")
public class ProductDelByIdServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String ids = req.getParameter("id");
        Integer id = ids == null || "".equals(ids) ? 0 : Integer.parseInt(ids);
        IproductService iproductService = new ProductServiceImpl();
        ResultModel resultModel = iproductService.del(id);
        JSONArray jsonArray = JSONArray.fromObject(resultModel);
        resp.getWriter().println(jsonArray);

    }
}
